define(function(require, exports, module) {
	'use strict';
    

    (function () {
        var ctrlNum = 6;
        $.widget('rk.wrStatistics_' + ctrlNum + 'PopupCtrl', $.rk.wrStatisticsPopupCtrl, {
            _create: function () {
                var me = this;
                var elem = me.element;
            },
            _init: function () {
                var me = this;
                me._super();
            },
            _handleData: function (data) {
                var me = this;
                var elem = me.element;

                var contracts = data.contracts;
                me._buildReasonMap(contracts);

                //最后一条数据
                var payments = data.payments;
                if (payments.length > 0)payments[payments.length - 1].isLast = true;
                for (var i = 0, len = payments.length; i < len; i++) {
                    var entity = payments[i];
                    var contract = me.reasonMap[entity.contractId + ''];
                    entity.contract = contract;
                    entity.amountText = numeral(entity.amount).format('0,0') + workreportService.getCurrencyUnit();
                }

                return data;
            },
            reasonMap: [],
            _buildReasonMap: function (contracts) {//输单理由
                var me = this;
                for (var i = 0, len = contracts.length; i < len; i++) {
                    var param = contracts[i];
                    me.reasonMap[param.id + ''] = param;
                }
            }
        });
    })()

});
